package cn.com.shopec.erp.stock.commo;

public class ObjectUtil {

	/**
	 * object转换为String
	 * 
	 * @param object
	 * @return
	 */
	public static String toString(Object object) {
		if (object != null) {
			return object.toString();
		}
		return "";
	}

	/**
	 * object转换为Integer
	 * 
	 * @param object
	 * @return
	 */
	public static Integer toInteger(Object object) {
		if (object != null) {
			return Integer.valueOf(object.toString());
		}
		return 0;
	}

	/**
	 * object转换为Long
	 * 
	 * @param object
	 * @return
	 */
	public static Long toLong(Object object) {
		if (object != null) {
			return Long.valueOf(object.toString());
		}
		return 0l;
	}

	/**
	 * object转换为double
	 * 
	 * @param object
	 * @return
	 */
	public static Double toDoubleObject(Object object) {
		if (object != null) {
			return Double.valueOf(object.toString());
		}
		return 0d;
	}

	/**
	 * Object比较（首参为null则返false）
	 * 
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public static boolean eq(Object arg1, Object arg2) {
		if (arg1 != null) {
			return arg1.equals(arg2);
		}
		return false;
	}

	/**
	 * Object比较（首参为null则返false）
	 * 
	 * @param arg1
	 * @param arg2
	 * @return
	 */
	public static boolean ne(Object arg1, Object arg2) {
		if (arg1 != null) {
			return !arg1.equals(arg2);
		}
		return false;
	}

	/**
	 * 判断对象是空
	 * 
	 * @param object
	 * @return
	 */
	public static boolean isNull(Object object) {
		return object == null;
	}

	/**
	 * 判断对象不是空
	 * 
	 * @param object
	 * @return
	 */
	public static boolean isNotNull(Object object) {
		return object != null;
	}

}
